package com.hy.memoryassistant;

import android.app.Activity;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;

public class EditNoteDetailActivity extends Activity {
	@Override 
	protected void onCreate(Bundle savedInstance) {
		super.onCreate(savedInstance);
		setContentView(R.layout.activity_note_detail);

		getActionBar().setDisplayHomeAsUpEnabled(true);

		if (savedInstance == null) {
			Bundle args = new Bundle();

			args.putLong(EditNoteDetailFragment.ARG_ITEM_ID, getIntent()
					.getLongExtra(EditNoteDetailFragment.ARG_ITEM_ID, 0));
			
			EditNoteDetailFragment frag = new EditNoteDetailFragment();
			frag.setArguments(args);
			FragmentTransaction transaction = getFragmentManager().beginTransaction();
			transaction.add(R.id.note_detail_container, frag);
			transaction.commit();

		}
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		if (item.getItemId() == android.R.id.home) {
			navigateUpTo(new Intent(this, NoteListActivity.class));
		}

		return super.onOptionsItemSelected(item);
	}
}
